package com.agriculture.controller;

import com.agriculture.common.R;
import com.agriculture.entity.ViewStar;
import com.agriculture.service.ViewStarService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@Slf4j
@RequestMapping("/viewStar")
public class ViewStarController {

    @Autowired
    private ViewStarService viewStarService;


    /**
     * 根据 getByUserId 查询商品评论
     * @param userId
     * @return
     */
    @GetMapping("/getByUserId")
    public R getByUserId(@RequestParam Long userId){
        LambdaQueryWrapper<ViewStar> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(ViewStar::getUserId, userId);
        List<ViewStar> viewStarList = viewStarService.list(queryWrapper);
        return R.success(viewStarList);
    }


}


























